#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    int matrixScore(vector<vector<int>>& A) {
        int maxScore = 0;
        
        int m = A.size();
        int n = A[0].size();
        

        maxScore = maxScore + m*pow(2, n - 1);

        for (int j = 1; j < n; j++) {
            int oneNum = 0;
            int zeroNum = 0;
            for (int i = 0; i < m; i++) {
                if ((A[i][j] == 0&&A[i][0]==1)||(A[i][j]==1&&A[i][0]==0)) {
                    ++zeroNum;
                }
                else if((A[i][j]==1&&A[i][0]==1)||(A[i][j]==0&&A[i][0]==0)){
                    ++oneNum;
                }
            }
            maxScore = maxScore + max(zeroNum,oneNum)*pow(2, n - j - 1);
        }

        return maxScore;
    }
};

//int main() {
//    vector<vector<int>> V = { {0,0,1,1},{1,0,1,0},{1,1,0,0} };
//    Solution S;
//    cout << S.matrixScore(V) << endl;
//}